package com.luokun.vue_shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.luokun.vue_shop.entity.SpPermission;
import com.luokun.vue_shop.mapper.SpPermissionMapper;
import com.luokun.vue_shop.model.SpPermissionModel;
import com.luokun.vue_shop.service.ISpPermissionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class SpPermissionServiceImpl extends ServiceImpl<SpPermissionMapper, SpPermission> implements ISpPermissionService {
    @Resource
    private SpPermissionMapper spPermissionMapper;


    @Override
    public List<SpPermissionModel> menus() {
        return spPermissionMapper.menus();
    }

    @Override
    public List<SpPermission> getSpPermissionlist() {
        return spPermissionMapper.selectList(null);
    }

    private List<SpPermission> getSpPermissionlist2(Integer pid) {
        QueryWrapper<SpPermission> queryWrapper = new QueryWrapper();
        queryWrapper.eq("ps_pid", pid);
        return spPermissionMapper.selectList(queryWrapper);

    }


    private Map<String, Object> pes() {
        List<SpPermission> list = this.getSpPermissionlist();
        for (SpPermission permission : list) {
            List<SpPermission> list1 = this.getSpPermissionlist2(permission.getPsId());
            if (list1 != null) {
                pes();
            }
        }
        return null;
    }
}
